package nz.co.kevindoran.googlechartsjsf;

import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponentBase;

@FacesComponent(value="googleChart")
public class UIGoogleChart extends UIComponentBase {

    public static final String DEFAULT_RENDERER = "nz.co.kevindoran.googlechartsjsf.ChartRenderer";
    public static final String COMPONENT_FAMILY = "nz.co.kevindoran.googlechartsjsf";
    
    private GoogleChartModel model;
    private String width;
    private String height;

   
    protected enum PropertyKeys {
        model;
        
        String toString;
        
        PropertyKeys(String toString) {
            this.toString = toString;
        }
        
        PropertyKeys() {}
        
        @Override
		public String toString() {
            return((this.toString != null) ? this.toString : super.toString());
        }
    }
    
    public UIGoogleChart() {
        // Used so that programmatic usage of the class, which doesn't get the benifit of the annotations can still use the class. Otherwise, the renderkit wouldn't be set.
        setRendererType(DEFAULT_RENDERER);
    }

    @Override
    public String getFamily() {
        return COMPONENT_FAMILY;
    }
    
    public void setModel(GoogleChartModel model) {
        this.model = model;
    }
    
    public GoogleChartModel getModel() {
        return model;
    }

    public String getWidth() {
        return width;
    }

    public void setWidth(String width) {
        this.width = width;
    }

    public String getHeight() {
        return height;
    }

    public void setHeight(String height) {
        this.height = height;
    }
}
